Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate try! macro #62672

Merged
merged 3 commits into from
Aug 9, 2019
Merged

Deprecate try! macro #62672

merged 3 commits into from
Aug 9, 2019

Conversation

tesuji
Copy link
Contributor

@tesuji tesuji commented Jul 14, 2019

@rust-highfive
Copy link
Collaborator

r? @KodrAus

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 14, 2019
@tesuji
Copy link
Contributor Author

tesuji commented Jul 14, 2019

r? @petrochenkov

@tesuji tesuji changed the title Deprecated try! macro Deprecate try! macro Jul 14, 2019
@petrochenkov
Copy link
Contributor

Implementation LGTM, but this should go through a library team FCP?

@petrochenkov petrochenkov added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 15, 2019
@petrochenkov
Copy link
Contributor

r? @dtolnay

@petrochenkov petrochenkov added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jul 15, 2019
@sfackler
Copy link
Member

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented Jul 15, 2019

Team member @sfackler has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jul 15, 2019
@matklad
Copy link
Member

matklad commented Jul 15, 2019

Just to make sure folks are aware, ?can generate measurably slower code than try! or a manual match: #37939. I don't think this needs to block the deprecation.

@dtolnay
Copy link
Member

dtolnay commented Jul 15, 2019

I am sad about this because of the ? performance issue, but ultimately I think it's fine to deprecate. In serde_derive we still don't use ? because it measurably hurts our benchmarks. Then again, we don't use try! either because it measurably hurts our compile time; none of our code needs the From::from error conversion and cutting it out saved significantly on type checking and borrow checking time.

Not a great situation... 😞

@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Jul 15, 2019
@rfcbot
Copy link

rfcbot commented Jul 15, 2019

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Jul 15, 2019
@est31
Copy link
Member

est31 commented Jul 15, 2019

@dtolnay your problems would be solved by providing proper customizability support to ?. The Try trait is only partial support for behavior customization and it's not even stable yet (you can't shadow it, for example, unlike the try macro). IMO it's far too early to pursue deprecation of try...

@est31
Copy link
Member

est31 commented Jul 15, 2019

I suggest anyone who needs the advanced features of try that aren't available for ? to use my try crate: https://crates.io/crates/try

I'll have to think about a good name replacement that is edition 2018 compliant.

@ghost
Copy link

ghost commented Jul 16, 2019

RELNOTES: The try! macro will be deprecated in 1.39.0 in favor of the ? operator.

EDIT: maybe even mention what @est31 said:

For anyone who wishes to continue to use the try! macro, I recommend using this try! crate: https://crates.io/crates/try

@mark-i-m

This comment has been minimized.

@rustbot

This comment has been minimized.

@Mark-Simulacrum Mark-Simulacrum added the relnotes Marks issues that should be documented in the release notes of the next release. label Jul 17, 2019
@Centril
Copy link
Contributor

Centril commented Aug 8, 2019

r? @Centril

r=me rollup when green + with requested changes.

@rust-highfive rust-highfive assigned Centril and unassigned dtolnay Aug 8, 2019
@tesuji tesuji force-pushed the deprecated-try-macro branch from 8c0ab27 to a7dd076 Compare August 8, 2019 16:21
@tesuji
Copy link
Contributor Author

tesuji commented Aug 8, 2019

CI is green now. I will push squashed commits after .

@Centril Centril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Aug 8, 2019
BO41 and others added 3 commits August 9, 2019 02:29
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
Co-Authored-By: Oliver Middleton <olliemail27@gmail.com>
@tesuji tesuji force-pushed the deprecated-try-macro branch from a7dd076 to 6842316 Compare August 9, 2019 02:30
@tesuji
Copy link
Contributor Author

tesuji commented Aug 9, 2019

Ping @Centril

@Centril
Copy link
Contributor

Centril commented Aug 9, 2019

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 9, 2019

📌 Commit 6842316 has been approved by Centril

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 9, 2019
Centril added a commit to Centril/rust that referenced this pull request Aug 9, 2019
bors added a commit that referenced this pull request Aug 9, 2019
Rollup of 7 pull requests

Successful merges:

 - #62672 (Deprecate `try!` macro)
 - #62950 (Check rustbook links on all platforms when running locally)
 - #63114 (Remove gensym in format_args)
 - #63397 (Add tests for some ICEs)
 - #63403 (Improve test output)
 - #63404 (enable flt2dec tests in Miri)
 - #63407 (reduce some test sizes in Miri)

Failed merges:

r? @ghost
@bors bors merged commit 6842316 into rust-lang:master Aug 9, 2019
@@ -302,6 +302,7 @@ macro_rules! debug_assert_ne {
/// ```
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.39.0", reason = "use the `?` operator instead")]
Copy link
Member

@RalfJung RalfJung Aug 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice that this means that nightly will start warning in a week -- which is an entire cycle before the deprecation is announced on the release notes.

We usually deprecate 3 releases in the future, so that between the deprecation announcement on a stable release and nightly starting to warn, there is still a full cycle. (Well, "usually" as in, both times I was involved in a future deprecation this is what we did -- in one case after some pushback when we wanted to go faster.) Right now, that would mean deprecating with Rust 1.41.

Copy link
Contributor

@Centril Centril Aug 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that matters much; try! has been deprecated for a long time in the docs and since ? was stabilized -- the change here is only due to a bugfix in the language.

@tesuji tesuji deleted the deprecated-try-macro branch August 9, 2019 16:16
flip1995 added a commit to flip1995/rust-clippy that referenced this pull request Aug 15, 2019
try macro is deprecated now, so Clippy will drop the support for it also
phi-gamma added a commit to phi-gamma/rust-mpd that referenced this pull request Nov 8, 2019
As of 1.39, the ``try!'' macro is deprecated:
rust-lang/rust#62672

This changeset contains purely mechanical substitutions, no
change in functionality.
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Nov 11, 2019
Pkgsrc changes:
 * Remove patch which no longer applies (but what about RPATH?)
 * Adapt a few patches to changed files upstream.

Upstream changes:

Version 1.39.0 (2019-11-07)
===========================

Language
--------
- [You can now create `async` functions and blocks with `async fn`,
  `async move {}`, and `async {}` respectively, and you can now call
  `.await` on async expressions.][63209]
- [You can now use certain attributes on function, closure, and function
  pointer parameters.][64010] These attributes include `cfg`, `cfg_attr`,
  `allow`, `warn`, `deny`, `forbid` as well as inert helper attributes used
  by procedural macro attributes applied to items. e.g.
  ```rust
  fn len(
      #[cfg(windows)] slice: &[u16],
      #[cfg(not(windows))] slice: &[u8],
  ) -> usize {
      slice.len()
  }
  ```
- [You can now take shared references to bind-by-move patterns in the
  `if` guards of `match` arms.][63118] e.g.
  ```rust
  fn main() {
      let array: Box<[u8; 4]> = Box::new([1, 2, 3, 4]);

      match array {
          nums
  //      ---- `nums` is bound by move.
              if nums.iter().sum::<u8>() == 10
  //                 ^------ `.iter()` implicitly takes a reference to `nums`.
          => {
              drop(nums);
  //          ----------- Legal as `nums` was bound by move and so we have ownership.
          }
          _ => unreachable!(),
      }
  }
  ```

Compiler
--------
- [Added tier 3\* support for the `i686-unknown-uefi` target.][64334]
- [Added tier 3 support for the `sparc64-unknown-openbsd` target.][63595]
- [rustc will now trim code snippets in diagnostics to fit in your terminal.]
  [63402] **Note** Cargo currently doesn't use this feature. Refer to
  [cargo#7315][cargo/7315] to track this feature's progress.
- [You can now pass `--show-output` argument to test binaries to print the
  output of successful tests.][62600]

\* Refer to Rust's [platform support page][forge-platform-support] for more
information on Rust's tiered platform support.

Libraries
---------
- [`Vec::new` and `String::new` are now `const` functions.][64028]
- [`LinkedList::new` is now a `const` function.][63684]
- [`str::len`, `[T]::len` and `str::as_bytes` are now `const` functions.][63770]
- [The `abs`, `wrapping_abs`, and `overflowing_abs` numeric functions are
  now `const`.][63786]

Stabilized APIs
---------------
- [`Pin::into_inner`]
- [`Instant::checked_duration_since`]
- [`Instant::saturating_duration_since`]

Cargo
-----
- [You can now publish git dependencies if supplied with a `version`.]
  [cargo/7237]
- [The `--all` flag has been renamed to `--workspace`.][cargo/7241] Using
  `--all` is now deprecated.

Misc
----
- [You can now pass `-Clinker` to rustdoc to control the linker used
  for compiling doctests.][63834]

Compatibility Notes
-------------------
- [Code that was previously accepted by the old borrow checker, but rejected by
  the NLL borrow checker is now a hard error in Rust 2018.][63565] This was
  previously a warning, and will also become a hard error in the Rust 2015
  edition in the 1.40.0 release.
- [`rustdoc` now requires `rustc` to be installed and in the same directory to
  run tests.][63827] This should improve performance when running a large
  amount of doctests.
- [The `try!` macro will now issue a deprecation warning.][62672] It is
  recommended to use the `?` operator instead.
- [`asinh(-0.0)` now correctly returns `-0.0`.][63698] Previously this
  returned `0.0`.

[62600]: rust-lang/rust#62600
[62672]: rust-lang/rust#62672
[63118]: rust-lang/rust#63118
[63209]: rust-lang/rust#63209
[63402]: rust-lang/rust#63402
[63565]: rust-lang/rust#63565
[63595]: rust-lang/rust#63595
[63684]: rust-lang/rust#63684
[63698]: rust-lang/rust#63698
[63770]: rust-lang/rust#63770
[63786]: rust-lang/rust#63786
[63827]: rust-lang/rust#63827
[63834]: rust-lang/rust#63834
[63927]: rust-lang/rust#63927
[63933]: rust-lang/rust#63933
[63934]: rust-lang/rust#63934
[63938]: rust-lang/rust#63938
[63940]: rust-lang/rust#63940
[63941]: rust-lang/rust#63941
[63945]: rust-lang/rust#63945
[64010]: rust-lang/rust#64010
[64028]: rust-lang/rust#64028
[64334]: rust-lang/rust#64334
[cargo/7237]: rust-lang/cargo#7237
[cargo/7241]: rust-lang/cargo#7241
[cargo/7315]: rust-lang/cargo#7315
[`Pin::into_inner`]: https://doc.rust-lang.org/std/pin/struct.Pin.html#method.into_inner
[`Instant::checked_duration_since`]: https://doc.rust-lang.org/std/time/struct.Instant.html#method.checked_duration_since
[`Instant::saturating_duration_since`]: https://doc.rust-lang.org/std/time/struct.Instant.html#method.saturating_duration_since
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate try! macro in favor of ? suggest ? over try!